/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package actuatedocumentor;

import java.io.Serializable;
import java.util.ArrayList;

/**
 *
 * @author Richard
 */
public class ReportVersion implements Serializable {
    private int version;
    private ArrayList globals;
    private OrderedHashMap classes;
    private ArrayList libraries;
    //private ArrayList superclasses;
    
    //storing of changes
    private OrderedHashMap classChangeMethodAdded;
    private OrderedHashMap classChangeMethodRemoved;
    private OrderedHashMap classChangeMethodChanged;
    private OrderedHashMap classRemoved;
    private OrderedHashMap classAdded;

    public void setClassAdded(OrderedHashMap classAdded) {
        this.classAdded = classAdded;
    }

    public void setClassChangeMethodAdded(OrderedHashMap classChangeMethodAdded) {
        this.classChangeMethodAdded = classChangeMethodAdded;
    }

    public void setClassChangeMethodChanged(OrderedHashMap classChangeMethodChanged) {
        this.classChangeMethodChanged = classChangeMethodChanged;
    }

    public void setClassChangeMethodRemoved(OrderedHashMap classChangeMethodRemoved) {
        this.classChangeMethodRemoved = classChangeMethodRemoved;
    }

    public void setClassRemoved(OrderedHashMap classRemoved) {
        this.classRemoved = classRemoved;
    }

    public OrderedHashMap getClassAdded() {
        return classAdded;
    }

    public OrderedHashMap getClassChangeMethodAdded() {
        return classChangeMethodAdded;
    }

    public OrderedHashMap getClassChangeMethodChanged() {
        return classChangeMethodChanged;
    }

    public OrderedHashMap getClassChangeMethodRemoved() {
        return classChangeMethodRemoved;
    }

    public OrderedHashMap getClassRemoved() {
        return classRemoved;
    }

 
    public ReportVersion() {
    }

    public ReportVersion(int version, ArrayList globals, OrderedHashMap classes, ArrayList libraries){//, ArrayList superclasses) {
        this.version = version;
        this.globals = globals;
        this.classes = classes;
        this.libraries = libraries;
        //this.superclasses = superclasses;
      //  linkSuperClassToClass();
    }

    //public void setSuperclasses(ArrayList superclasses) {
    //    this.superclasses = superclasses;
    //}

    //public ArrayList getSuperclasses() {
    //    return superclasses;
    //}

    public String showChanges(){
        String returnString = "Classes Added \n\r";
        
        for(int i = 0; i<this.getClassAdded().size();i++){
            returnString = returnString+((ActuateClass)this.getClassAdded().getArrayList().get(i)).toString()+"\n\r\n\r";
        }
        
        returnString = returnString + "Classes Removed \n\r";
        
        for(int i = 0; i<this.getClassRemoved().size();i++){
            returnString = returnString+((ActuateClass)this.getClassRemoved().getArrayList().get(i)).toString()+"\n\r\n\r";
        }

        returnString = returnString + "Classes Changed \n\r Methods Added \n\r";
        
        for(int i = 0; i<this.getClassChangeMethodAdded().size();i++){
            returnString = returnString+((ActuateClass)this.getClassChangeMethodAdded().getArrayList().get(i)).toString()+"\n\r\n\r";
        }
        
        returnString = returnString + "Methods Removed \n\r";
        
        for(int i = 0; i<this.getClassChangeMethodRemoved().size();i++){
            returnString = returnString+((ActuateClass)this.getClassChangeMethodRemoved().getArrayList().get(i)).toString()+"\n\r\n\r";
        }
        
        returnString = returnString + "Methods Changed \n\r";
        
        for(int i = 0; i<this.getClassChangeMethodChanged().size();i++){
            returnString = returnString+((ActuateClass)this.getClassChangeMethodChanged().getArrayList().get(i)).toString()+"\n\r\n\r";
        }
        
        return returnString;
    } 
    
    @Override
    public String toString() {
        String returnString = "Version = "+this.version+ "\n\r";
        for (int i = 0; i<globals.size(); i++){
            returnString = returnString + "Global Variable"+(i+1)+" = "+((GlobalVariable)globals.get(i)).toString()+"\n\r"; 
            
        }

        
        ArrayList al = ((OrderedHashMap)classes.clone()).getArrayList();
        
        for(int i = 0; i<al.size();i++){
        //while(it.hasNext()){
            
            returnString = returnString + "Class"+(i+1)+" = "+((ActuateClass)al.get(i)).toString()+"\n\r";
        }
        
        
        for (int i = 0; i<libraries.size(); i++){
            returnString = returnString + "Library"+(i+1)+" = "+libraries.get(i)+"\n\r"; 
            
        }
        
        
        return returnString;
    }

    public String getCompareString() {
        String returnString = "";
        for (int i = 0; i<globals.size(); i++){
            returnString = returnString + "Global Variable"+(i+1)+" = "+((GlobalVariable)globals.get(i)).toString()+"\n\r"; 
            
        }
        
        ArrayList al = ((OrderedHashMap)classes.clone()).getArrayList();
        
        for(int i = 0; i<al.size(); i++){
        //while(it.hasNext()){
            
            returnString = returnString + "Class"+(i+1)+" = "+((ActuateClass)al.get(i)).toString()+"\n\r"; 
            
        }
        
        for (int i = 0; i<libraries.size(); i++){
            returnString = returnString + "Library"+(i+1)+" = "+libraries.get(i)+"\n\r"; 
            
        }
        
      //  for (int i = 0; i<superclasses.size(); i++){
      //      returnString = returnString + "Class "+((ActuateClass)superclasses.get(i)).getClassname()+
      //              " Superclass "+((ActuateClass)superclasses.get(i)).getSuperclassname()+"\n\r";
      //  }
        
        
        
        
        return returnString;
    }

    //private void linkSuperClassToClass(){
    //    if(this.superclasses!=null&&this.classes!=null){
            
           
            
            
            
            
            
            
            
      //      for(int i = 0; i<superclasses.size(); i++){
      //          ActuateClass acTemp = (ActuateClass)superclasses.get(i);
                
      //          boolean classMatch = false;
      //          for(int x = 0; x<classes.size();x++){
      //              ActuateClass ac = (ActuateClass)classes.get(x);
                    
      //              if(acTemp.getClassname().compareTo(ac.getClassname())==0){
      //                  ac.setSuperclassname(acTemp.getSuperclassname());
      //                  classMatch = true;
      //              }
      //          }
      //          if(classMatch==false){
      //              classes.add(acTemp);
      //          }
      //      }
      //  }
        
        
      //   for(int i = 0; i<classes.size();i++){
      //              ActuateClass ac = (ActuateClass)classes.get(i);
      //     System.out.println(ac.getClassname());     
      //      }
           
        
    //}
    
    public void setVersion(int version) {
        this.version = version;
    }

    public int getVersion() {
        return version;
    }

    
    public ArrayList getGlobals() {
        return globals;
    }

    public ArrayList getLibraries() {
        return libraries;
    }

    public OrderedHashMap getClasses() {
        return classes;
    }

    public void setGlobals(ArrayList globals) {
        this.globals = globals;
    }

    public void setLibraries(ArrayList libraries) {
        this.libraries = libraries;
    }

    public void setClasses(OrderedHashMap classes) {
        this.classes = classes;
    }
    

}
